/ Assembly List / LJCDataAccess / DataAccess / GetProcedureDataTable

Namespace - LJCDataAccess


Parameters
procedureName - The procedure name.
parameters - The procedure parameters.

Returns

A reference to the DataTable object.

Syntax

C#
public DataTable GetProcedureDataTable(String procedureName, ProcedureParameters parameters)

Executes a Stored Procedure and retrieves the DataTable object. (E)

Example

C#
// See the DataAccess setup code on the DataAccess class page.

// Executes a Select statement and retrieves the DataTable object.
private static void GetProcedureDataTable(DataAccess dataAccess)
{
    // Add(string parameterName, SqlDbType sqlDbType, int size
    //   , object value = null, ParameterDirection direction = ParameterDirection.Input)
    var parameters = new ProcedureParameters()
    {
        { "@ID", SqlDbType.Int, 0, 8 }
    };

    string procedureName = "dbo.sp_RetrieveByID";

    var dataTable = dataAccess.GetProcedureDataTable(procedureName
        , parameters);
    if (dataTable != null)
    {
        foreach (DataRow dataRow in dataTable.Rows)
        {
            for int index = 0; index < dataTable.Columns.Count; index++)
            {
                string value = dataRow[index].ToString();
            }
        }
    }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.